home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
disk_425.arc
/
SORT-B.LIB
< prev
next >
Wrap
Text File
|
1985-04-03
|
639b
|
34 lines
{ --> 176}
procedure {bubble} sort(var a: ary; n: integer);
{ adapted from 'Introduction to PASCAL',
R.Zaks, Sybex, 1980 }
var no_change : boolean;
j : integer;
procedure swap(p,q: real);
var hold : real;
begin
hold:=p;
p:=q;
q:=hold
end; { swap }
begin { procedure sort }
repeat
no_change:=true;
for j:=1 to n-1 do
begin
if a[j]>a[j+1] then
begin
swap(a[j],a[j+1]);
no_change:=false
end
end { for }
until no_change
end; { procedure sort }